#pragma once

#include "../Common/Common.h"
#include "Camera2D.h"
#include "OsgViewerBase.h"

const int	TEXTURE_WIDTH	= 1024;
const int	TEXTURE_HEIGHT	= 1024;


class PSDF_CORE_DLL_DECL StaticNodeGroup : public Group, public EventHandler
{
public:
	StaticNodeGroup( OsgViewerBase * parentViewer );

	~StaticNodeGroup() {}

private:
	StaticNodeGroup( const StaticNodeGroup & ) {}

public:
	virtual bool					addChild( Node * child );

	virtual void					handleSystemEvent( unsigned eventType, int param1, int param2 );
	virtual string					getModuleName() { return PSDFCore_Lib; }

	virtual void					traverse(NodeVisitor& nv);

private:
	void							createTextureCamera();
	void							createTexturedSquare();
	void							createBoardCamera();

	void							onCameraChanged( int param1, int param2 );
	void							onLayerChanged();
	void							onFrameBegin();

	Geometry*						createGeometry( Texture2D * texture, double x1, double y1, double x2, double y2 );
	void							adjustTexturedSquare( Camera * mainCamera );

private:
	OsgViewerBase *					_parentViewer;

	ref_ptr<Geode>					_texturedSquare;
	ref_ptr<Texture2D>				_texture;
	ref_ptr<Camera>					_textureCamera;
	ref_ptr<Camera>					_boardCamera;

	short							_delay;
	short							_initDelay;
};
